//
//  DiscoverViewController.swift
//  夏祖强的新浪微博
//
//  Created by 夏祖强 on 16/5/10.
//  Copyright © 2016年 夏祖强. All rights reserved.
//

import UIKit
//Cell可重用标识符
private let CZDiscoverCellID = "CZDidcoverCellID"
//
class DiscoverViewController: RootViewController {

    override func viewDidLoad() {
        //设置刷新控件
        setupRefreshControl()
        super.viewDidLoad()
        
        //注册重用cell
        tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: CZDiscoverCellID)
        
        visitorView?.setupInfo("visitordiscover_image_message",message: "登陆后,最新,最热微博尽在掌握,不再会于是是潮流檫肩而过")
    }
    
    override func loadData() {
        
        refreshControl.beginRefreshing()
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(Double(NSEC_PER_SEC) * 1.0)), dispatch_get_main_queue()){ () ->Void in
            self.dataCount += 10
            
            //结束刷新
            self.refreshControl.endRefreshing()
            self.pullupView.stopAnimating()
            
            self.tableView.reloadData()
            
        }

    }

    //私有属性
    private var dataCount = 0

}
//MARK - 数据源方法

extension DiscoverViewController {
    
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataCount
    }
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier(CZDiscoverCellID, forIndexPath: indexPath)
        cell.textLabel?.text = "\(indexPath.row)"
        
        return cell
    }
 }